﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;

namespace SharpSqlAnalyzer
{
	// Token: 0x0200004C RID: 76
	internal class TLexerImpala : TCustomLexer
	{
		// Token: 0x06000110 RID: 272 RVA: 0x00017BA9 File Offset: 0x00015DA9
		static TLexerImpala()
		{
			TLexerImpala.table_file = "/SharpSqlAnalyzer/parser/impala/impala_lex_table.txt";
			TLexerImpala.inittable();
		}

		// Token: 0x06000111 RID: 273 RVA: 0x00017BD4 File Offset: 0x00015DD4
		internal TLexerImpala()
		{
			this.dbvendor = EDbVendor.dbvimpala;
			this.sourcetokens = new TSourceTokenList();
		}

		// Token: 0x06000112 RID: 274 RVA: 0x00017BEE File Offset: 0x00015DEE
		public static bool canBeColumnName(int tokencode)
		{
			return TCustomLexer.canBeColumnName(tokencode, TLexerImpala.keywordTypeList);
		}

		// Token: 0x06000113 RID: 275 RVA: 0x00017BFB File Offset: 0x00015DFB
		public static int iskeyword(string str)
		{
			return TCustomLexer.iskeyword(str, TLexerImpala.keywordValueList);
		}

		// Token: 0x06000114 RID: 276 RVA: 0x00017C08 File Offset: 0x00015E08
		public static int getkeywordvalue(string keyword)
		{
			return TCustomLexer.getkeywordvalue(keyword, TLexerImpala.keywordValueList);
		}

        // Token: 0x06000115 RID: 277 RVA: 0x00017C18 File Offset: 0x00015E18
        internal override int yylex()
        {
            do
            {
                yynew();
                while (true)
                {
                    int i;
                    for (i = yykl[yystate]; i <= yykh[yystate]; i++)
                    {
                        yymark(yyk[i]);
                    }
                    for (i = yymh[yystate]; i >= yyml[yystate]; i--)
                    {
                        yymatch(yym[i]);
                    }
                    if (yytl[yystate] > yyth[yystate])
                    {
                        break;
                    }
                    yyscan();
                    i = yytl[yystate];
                    totablechar();
                    for (; i <= yyth[yystate] && !charinarray(yytablechar, yyt[i].cc); i++)
                    {
                    }
                    if (i > yyth[yystate])
                    {
                        break;
                    }
                    yystate = yyt[i].s;
                }
                do
                {
                    int yyruleno;
                    if ((yyruleno = yyfind()) != -1)
                    {
                        yyaction(yyruleno);
                        continue;
                    }
                    if (!yydefault() && yywrap())
                    {
                        yyclear();
                        returni(0);
                    }
                    break;
                }
                while (yyreject);
            }
            while (!yydone);
            return yyretval;
        }

        // Token: 0x06000116 RID: 278 RVA: 0x00017D5C File Offset: 0x00015F5C
        internal static void inittable()
		{
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			bool flag4 = false;
			bool flag5 = false;
			bool flag6 = false;
			bool flag7 = false;
			bool flag8 = false;
			bool flag9 = false;
			bool flag10 = false;
			bool flag11 = false;
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			int num6 = 0;
			int num7 = 0;
			int num8 = 0;
			int num9 = 0;
			int num10 = 0;
			int num11 = 0;
			TLexerImpala.keywordValueList.Clear();
			TLexerImpala.keywordTypeList.Clear();
			StreamReader streamReader = TCustomLexer.readSymbolTable("impala", "lex");
			try
			{
				string text;
				while ((text = streamReader.ReadLine()) != null)
				{
					if (text.Trim().StartsWith("yynmarks=", StringComparison.Ordinal))
					{
						TLexerImpala.yynmarks = int.Parse(text.Split(new char[]
						{
							'=',
							';'
						}, StringSplitOptions.RemoveEmptyEntries)[1].Trim());
						TLexerImpala.yyk = new int[TLexerImpala.yynmarks + 1];
					}
					else if (text.Trim().StartsWith("yynmatches=", StringComparison.Ordinal))
					{
						TLexerImpala.yynmatches = int.Parse(text.Split(new char[]
						{
							'=',
							';'
						}, StringSplitOptions.RemoveEmptyEntries)[1].Trim());
						TLexerImpala.yym = new int[TLexerImpala.yynmatches + 1];
					}
					else if (text.Trim().StartsWith("yyntrans=", StringComparison.Ordinal))
					{
						TLexerImpala.yyntrans = int.Parse(text.Split(new char[]
						{
							'=',
							';'
						}, StringSplitOptions.RemoveEmptyEntries)[1].Trim());
						TLexerImpala.yytint = new int[TLexerImpala.yyntrans + 1];
						TLexerImpala.yyt = new TYytRec[TLexerImpala.yyntrans + 1];
					}
					else if (text.Trim().StartsWith("yynstates=", StringComparison.Ordinal))
					{
						TLexerImpala.yynstates = int.Parse(text.Split(new char[]
						{
							'=',
							';'
						}, StringSplitOptions.RemoveEmptyEntries)[1].Trim());
						TLexerImpala.yykl = new int[TLexerImpala.yynstates];
						TLexerImpala.yykh = new int[TLexerImpala.yynstates];
						TLexerImpala.yyml = new int[TLexerImpala.yynstates];
						TLexerImpala.yymh = new int[TLexerImpala.yynstates];
						TLexerImpala.yytl = new int[TLexerImpala.yynstates];
						TLexerImpala.yyth = new int[TLexerImpala.yynstates];
					}
					else if (text.Trim().StartsWith("<end>", StringComparison.Ordinal))
					{
						if (flag)
						{
							flag = false;
							if (TLexerImpala.yynmarks + 1 != num)
							{
								Console.WriteLine("required1:" + TLexerImpala.yynmarks.ToString() + " actually:" + (num - 1).ToString());
							}
						}
						else if (flag2)
						{
							flag2 = false;
							if (TLexerImpala.yynmatches + 1 != num2)
							{
								Console.WriteLine("required2:" + TLexerImpala.yynmatches.ToString() + " actually:" + (num2 - 1).ToString());
							}
						}
						else if (flag3)
						{
							flag3 = false;
							if (TLexerImpala.yynstates != num3)
							{
								Console.WriteLine("required3:" + TLexerImpala.yynstates.ToString() + " actually:" + num3.ToString());
							}
						}
						else if (flag4)
						{
							flag4 = false;
							if (TLexerImpala.yynstates != num4)
							{
								Console.WriteLine("required4:" + TLexerImpala.yynstates.ToString() + " actually:" + num4.ToString());
							}
						}
						else if (flag5)
						{
							flag5 = false;
							if (TLexerImpala.yynstates != num5)
							{
								Console.WriteLine("required5:" + TLexerImpala.yynstates.ToString() + " actually:" + num5.ToString());
							}
						}
						else if (flag6)
						{
							flag6 = false;
							if (TLexerImpala.yynstates != num6)
							{
								Console.WriteLine("required:" + TLexerImpala.yynstates.ToString() + " actually:" + num6.ToString());
							}
						}
						else if (flag7)
						{
							flag7 = false;
							if (TLexerImpala.yynstates != num7)
							{
								Console.WriteLine("required6:" + TLexerImpala.yynstates.ToString() + " actually:" + num7.ToString());
							}
						}
						else if (flag8)
						{
							flag8 = false;
							if (TLexerImpala.yynstates != num8)
							{
								Console.WriteLine("required7:" + TLexerImpala.yynstates.ToString() + " actually:" + num8.ToString());
							}
						}
						else if (flag9)
						{
							flag9 = false;
							if (TLexerImpala.yyntrans + 1 != num9)
							{
								Console.WriteLine("required8:" + TLexerImpala.yyntrans.ToString() + " actually:" + (num9 - 1).ToString());
							}
						}
						else if (flag10)
						{
							flag10 = false;
							if (TLexerImpala.yyntrans + 1 != num10)
							{
								Console.WriteLine("required9:" + TLexerImpala.yyntrans.ToString() + " actually:" + (num10 - 1).ToString());
							}
						}
						else if (flag11)
						{
							flag11 = false;
						}
					}
					else if (text.Trim().StartsWith("yyk =", StringComparison.Ordinal))
					{
						flag = true;
					}
					else if (text.Trim().StartsWith("yym =", StringComparison.Ordinal))
					{
						flag2 = true;
					}
					else if (text.Trim().StartsWith("yykl =", StringComparison.Ordinal))
					{
						flag3 = true;
					}
					else if (text.Trim().StartsWith("yykh =", StringComparison.Ordinal))
					{
						flag4 = true;
					}
					else if (text.Trim().StartsWith("yyml =", StringComparison.Ordinal))
					{
						flag5 = true;
					}
					else if (text.Trim().StartsWith("yymh =", StringComparison.Ordinal))
					{
						flag6 = true;
					}
					else if (text.Trim().StartsWith("yytl =", StringComparison.Ordinal))
					{
						flag7 = true;
					}
					else if (text.Trim().StartsWith("yyth =", StringComparison.Ordinal))
					{
						flag8 = true;
					}
					else if (text.Trim().StartsWith("yytint =", StringComparison.Ordinal))
					{
						flag9 = true;
					}
					else if (text.Trim().StartsWith("yyt =", StringComparison.Ordinal))
					{
						flag10 = true;
					}
					else if (text.Trim().StartsWith("keywordsvalue =", StringComparison.Ordinal))
					{
						flag11 = true;
					}
					else if (flag)
					{
						string[] array = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int i = 0; i < array.Length; i++)
						{
							TLexerImpala.yyk[num++] = int.Parse(array[i].Trim());
						}
					}
					else if (flag2)
					{
						string[] array2 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int j = 0; j < array2.Length; j++)
						{
							TLexerImpala.yym[num2++] = int.Parse(array2[j].Trim());
						}
					}
					else if (flag3)
					{
						string[] array3 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int k = 0; k < array3.Length; k++)
						{
							TLexerImpala.yykl[num3++] = int.Parse(array3[k].Trim());
						}
					}
					else if (flag4)
					{
						string[] array4 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int l = 0; l < array4.Length; l++)
						{
							TLexerImpala.yykh[num4++] = int.Parse(array4[l].Trim());
						}
					}
					else if (flag5)
					{
						string[] array5 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int m = 0; m < array5.Length; m++)
						{
							TLexerImpala.yyml[num5++] = int.Parse(array5[m].Trim());
						}
					}
					else if (flag6)
					{
						string[] array6 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int n = 0; n < array6.Length; n++)
						{
							TLexerImpala.yymh[num6++] = int.Parse(array6[n].Trim());
						}
					}
					else if (flag7)
					{
						string[] array7 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int num12 = 0; num12 < array7.Length; num12++)
						{
							TLexerImpala.yytl[num7++] = int.Parse(array7[num12].Trim());
						}
					}
					else if (flag8)
					{
						string[] array8 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int num13 = 0; num13 < array8.Length; num13++)
						{
							TLexerImpala.yyth[num8++] = int.Parse(array8[num13].Trim());
						}
					}
					else if (flag9)
					{
						string[] array9 = text.Split(new char[]
						{
							','
						}, StringSplitOptions.RemoveEmptyEntries);
						for (int num14 = 0; num14 < array9.Length; num14++)
						{
							TLexerImpala.yytint[num9++] = int.Parse(array9[num14].Trim());
						}
					}
					else if (flag10)
					{
						num11 = 0;
						string[] array10 = text.Trim().Split(new string[]
						{
							",,"
						}, StringSplitOptions.RemoveEmptyEntries);
						char[] array11 = new char[array10.Length];
						for (int num15 = 0; num15 < array10.Length; num15++)
						{
							if (array10[num15].StartsWith("'", StringComparison.Ordinal))
							{
								if (array10[num15].Length == 3)
								{
									array11[num11++] = array10[num15][1];
								}
								else if (array10[num15].Length == 4)
								{
									array11[num11++] = array10[num15][2];
								}
								else
								{
									Console.WriteLine(" read yytstr error, error string is " + array10[num15] + "line: " + num10.ToString());
								}
							}
							else
							{
								try
								{
									array11[num11++] = (char)int.Parse(array10[num15]);
								}
								catch (FormatException ex)
								{
									Console.WriteLine("NumberFormatException: " + ex.Message);
								}
							}
						}
						TLexerImpala.yyt[num10] = new TYytRec(array11, TLexerImpala.yytint[num10]);
						num10++;
					}
					else if (flag11)
					{
						string[] array12 = text.Split(new char[]
						{
							'='
						}, StringSplitOptions.RemoveEmptyEntries);
						TLexerImpala.keywordValueList[array12[0].ToUpper()] = int.Parse(array12[1]);
						TLexerImpala.keywordTypeList[int.Parse(array12[1])] = int.Parse(array12[2]);
					}
				}
			}
			catch (IOException ex2)
			{
				Console.WriteLine(ex2.ToString());
			}
		}

		// Token: 0x06000117 RID: 279 RVA: 0x0001879C File Offset: 0x0001699C
		internal override void yyaction(int yyruleno)
		{
            //RuntimeHelpers.InitializeArray(new char[7], fieldof(<PrivateImplementationDetails>.C26324E724DBE67E9EA29B8827462613F2AA946EA1F4E3BB44FC3C4B1CA81F4E).FieldHandle);
            _ = new char[7] { '=', '+', '-', '*', '/', '>', '<' };
            this.yylvalstr = this.getyytext();
			switch (yyruleno)
			{
			case 1:
				this.addlit(this.yylvalstr, this.yytextlen);
				if (this.xcdepth <= 0)
				{
					this.start(2);
					this.yylvalstr = this.litbufdup();
					this.returni(257);
					return;
				}
				this.xcdepth--;
				return;
			case 2:
				this.xcdepth++;
				this.yyless(2);
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 3:
				if (this.getyysstate() == 8)
				{
					this.nchars = this.yytextlen;
					this.addlit(this.yylvalstr, this.yytextlen - 1);
					this.yyless(this.nchars - 1);
					return;
				}
				this.xcdepth = 0;
				this.start(4);
				this.startlit();
				this.yyless(2);
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 4:
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 5:
				this.start(2);
				this.addlit(this.yylvalstr, this.yytextlen);
				this.yylvalstr = this.litbufdup();
				this.returni(275);
				return;
			case 6:
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 7:
				if (this.yysstate == 6)
				{
					this.addlit(this.yylvalstr, this.yytextlen);
					return;
				}
				this.start(8);
				this.startlit();
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 8:
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 9:
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 10:
				this.dummych1 = this.get_char();
				this.addlit(this.yylvalstr + this.dummych1.ToString(), this.yytextlen + 1);
				return;
			case 11:
				this.dummych1 = this.get_char();
				this.addlit(this.yylvalstr + this.dummych1.ToString(), this.yytextlen + 1);
				return;
			case 12:
				this.start(2);
				this.addlit(this.yylvalstr, this.yytextlen);
				if (this.literallen == 0)
				{
					this.returni(274);
				}
				if (this.literallen >= 255)
				{
					this.setlengthofliteralbuf(255);
					this.literallen = 255;
				}
				this.yylvalstr = this.litbufdup();
				this.returni(275);
				return;
			case 13:
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 14:
				this.start(6);
				this.startlit();
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 15:
				this.dummych1 = this.get_char();
				this.unget_char(this.dummych1);
				if (this.dummych1 == '\n')
				{
					this.dummych1 = this.get_char();
					this.addlit(this.yylvalstr + this.dummych1.ToString(), this.yytextlen + 1);
					return;
				}
				this.addlit(this.yylvalstr, this.yytextlen);
				return;
			case 16:
				this.returni(260);
				return;
			case 17:
				this.returni(259);
				return;
			case 18:
				if (this.getyysstate() == 8 || this.getyysstate() == 6)
				{
					this.addlit(this.yylvalstr, 1);
					this.yyless(1);
					return;
				}
				this.returni(258);
				return;
			case 19:
				this.returni(46);
				return;
			case 20:
				this.returni(58);
				return;
			case 21:
				this.returni(44);
				return;
			case 22:
				this.returni(59);
				return;
			case 23:
				this.returni(40);
				return;
			case 24:
				this.returni(41);
				return;
			case 25:
				this.returni(91);
				return;
			case 26:
				this.returni(93);
				return;
			case 27:
				this.returni(123);
				return;
			case 28:
				this.returni(125);
				return;
			case 29:
				this.returni(60);
				return;
			case 30:
				this.returni(62);
				return;
			case 31:
				this.returni(47);
				return;
			case 32:
				this.returni(43);
				return;
			case 33:
				this.returni(45);
				return;
			case 34:
				this.returni(42);
				return;
			case 35:
				this.returni(37);
				return;
			case 36:
				this.returni(38);
				return;
			case 37:
				this.returni(126);
				return;
			case 38:
				this.returni(124);
				return;
			case 39:
				this.returni(94);
				return;
			case 40:
				this.returni(63);
				return;
			case 41:
				this.returni(36);
				return;
			case 42:
				this.returni(289);
				return;
			case 43:
				this.returni(288);
				return;
			case 44:
				this.returni(290);
				return;
			case 45:
				this.returni(294);
				return;
			case 46:
				this.returni(33);
				return;
			case 47:
				this.returni(296);
				return;
			case 48:
				this.returni(297);
				return;
			case 49:
				this.returni(293);
				return;
			case 50:
				this.returni(277);
				return;
			case 51:
				this.returni(278);
				return;
			case 52:
				this.returni(279);
				return;
			case 53:
				this.returni(280);
				return;
			case 54:
				this.returni(273);
				return;
			case 55:
				this.returni(272);
				return;
			case 56:
				this.returni(276);
				return;
			case 57:
			{
				int n;
				if ((n = TLexerImpala.iskeyword(this.yylvalstr)) != -1)
				{
					this.returni(n);
					return;
				}
				this.returni(264);
				return;
			}
			case 58:
				this.returni(270);
				return;
			case 59:
				this.returni(271);
				return;
			case 60:
				this.returni(274);
				return;
			default:
				Console.WriteLine("fatal error in yyaction");
				return;
			}
		}

		// Token: 0x04000E4B RID: 3659
		internal static int yynmarks = 0;

		// Token: 0x04000E4C RID: 3660
		internal static int yynmatches;

		// Token: 0x04000E4D RID: 3661
		internal static int yyntrans;

		// Token: 0x04000E4E RID: 3662
		internal static int yynstates;

		// Token: 0x04000E4F RID: 3663
		internal static int[] yyk;

		// Token: 0x04000E50 RID: 3664
		internal static int[] yym;

		// Token: 0x04000E51 RID: 3665
		internal static int[] yytint;

		// Token: 0x04000E52 RID: 3666
		internal static TYytRec[] yyt;

		// Token: 0x04000E53 RID: 3667
		internal static int[] yykl;

		// Token: 0x04000E54 RID: 3668
		internal static int[] yykh;

		// Token: 0x04000E55 RID: 3669
		internal static int[] yyml;

		// Token: 0x04000E56 RID: 3670
		internal static int[] yymh;

		// Token: 0x04000E57 RID: 3671
		internal static int[] yytl;

		// Token: 0x04000E58 RID: 3672
		internal static int[] yyth;

		// Token: 0x04000E59 RID: 3673
		private static string[] keywordlist;

		// Token: 0x04000E5A RID: 3674
		internal static string table_file;

		// Token: 0x04000E5B RID: 3675
		internal static IDictionary<string, int> keywordValueList = new Dictionary<string, int>();

		// Token: 0x04000E5C RID: 3676
		internal static IDictionary<int, int> keywordTypeList = new Dictionary<int, int>();

		// Token: 0x04000E5D RID: 3677
		public TSourceTokenList sourcetokens;
	}
}
